package com.xd.core.business.mapper;

import com.xd.core.business.entity.ProductCompanyTiered;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author ZX
 * @since 2025-05-28
 */
public interface ProductCompanyTieredMapper extends BaseMapper<ProductCompanyTiered> {
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("INSERT INTO product_company_tiered (product_id, charge_amount_min, charge_amount_max, company_id,charge_proportion) " +
            "VALUES (#{productId}, #{chargeAmountMin}, #{chargeAmountMax}, #{companyId},#{chargeProportion})")
    int insert(ProductCompanyTiered tiered);

    // 批量插入方法
    default int insertBatch(List<ProductCompanyTiered> list) {
        return list.stream().mapToInt(this::insert).sum();
    }
}
